s = input()
s2 = ""
st = "({<["
en = ")}>]"
ans = True 
for x in s:
    if x in st:
        s2 += x
    elif x in en:
        if en.find(x) == st.find(s2[-1]):
            s2 = s2[:-1]
        else:
            ans = False
            break
if s2:
    ans = False
print(ans)